package com.csyaonie.android.broadcast;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import com.csyaonie.android.R;

public class BroadcastActivity2 extends AppCompatActivity {

    private Button b_btn1;
    private Button b_btn2;

    private static final String TAG = "BroadcastActivity2";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_broadcast2);

        b_btn1=findViewById(R.id.b_btn1);
        b_btn2=findViewById(R.id.b_btn2);
        b_btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent("com.csyaonie.update");
                LocalBroadcastManager.getInstance(BroadcastActivity2.this).sendBroadcast(intent);

            }
        });
        b_btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent("MY_BROADCAST");
                intent.setClassName(BroadcastActivity2.this,"com.csyaonie.android.broadcast.MyReceiver");
                sendBroadcast(intent);
            }
        });
    }
}